package com.itheima.springbootdemo02.controller;

import com.itheima.common.MessageConst;
import com.itheima.entity.Result;
import com.itheima.pojo.User;
import com.itheima.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户控制器
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/add")
    public Result add(User user){
        log.info("[用户-添加]data:{}",user);
        // 调用service添加数据
        userService.add(user);
        return new Result(true, MessageConst.ACTION_SUCCESS);
    }
}
